package com.zxg.zbc.web.common.util;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.citrus.service.pipeline.PipelineContext;
import com.alibaba.citrus.service.pipeline.support.AbstractValve;
import com.zxg.zbc.web.common.config.SessionConfig;

public class DomianValve extends AbstractValve {
  final static Logger         log = LoggerFactory.getLogger(DomianValve.class);
  @Autowired
  private HttpServletRequest  request;
  @Autowired
  private HttpServletResponse response;
  @Autowired
  protected HttpSession       session;

  @Override
  protected void init() throws Exception {

  }

  public void invoke(PipelineContext pipelineContext) throws Exception {
//    String url = request.getRequestURL().toString();
//    boolean json = this.request.getRequestURL().toString().endsWith("json");
//    if (!json) {
//      if (url.contains("/buyer/")) {
//        session.setAttribute(SessionConfig.SESSION_PAGE_TYPE, SessionConfig.SESSION_USER_TYPE_BUYER);
//      } else if (url.contains("/seller/")) {
//        session.setAttribute(SessionConfig.SESSION_PAGE_TYPE, SessionConfig.SESSION_USER_TYPE_SELLER);
//      } else if (url.contains("/sellerh5/")) {
//        session.setAttribute(SessionConfig.SESSION_PAGE_TYPE, SessionConfig.SESSION_USER_TYPE_SELLER);
//      } else if (url.contains("/ad/")) {
//        session.setAttribute(SessionConfig.SESSION_PAGE_TYPE, SessionConfig.SESSION_USER_TYPE_ADMIN);
//      }
//
//    }
    pipelineContext.invokeNext();
  }

}
